/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ec.socialfun.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author hp
 */
@Entity
@Table(name = "rol")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Rol.findAll", query = "SELECT r FROM Rol r"),
    @NamedQuery(name = "Rol.findByRoCodigo", query = "SELECT r FROM Rol r WHERE r.roCodigo = :roCodigo"),
    @NamedQuery(name = "Rol.findByRoNombre", query = "SELECT r FROM Rol r WHERE r.roNombre = :roNombre")})
public class Rol implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "RO_CODIGO")
    private Integer roCodigo;
    @Basic(optional = false)
    @Column(name = "RO_NOMBRE")
    private String roNombre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "roCodigo")
    private List<UsuarioRol> usuarioRolList;

    public Rol() {
    }

    public Rol(Integer roCodigo) {
        this.roCodigo = roCodigo;
    }

    public Rol(Integer roCodigo, String roNombre) {
        this.roCodigo = roCodigo;
        this.roNombre = roNombre;
    }

    public Integer getRoCodigo() {
        return roCodigo;
    }

    public void setRoCodigo(Integer roCodigo) {
        this.roCodigo = roCodigo;
    }

    public String getRoNombre() {
        return roNombre;
    }

    public void setRoNombre(String roNombre) {
        this.roNombre = roNombre;
    }

    @XmlTransient
    public List<UsuarioRol> getUsuarioRolList() {
        return usuarioRolList;
    }

    public void setUsuarioRolList(List<UsuarioRol> usuarioRolList) {
        this.usuarioRolList = usuarioRolList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (roCodigo != null ? roCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Rol)) {
            return false;
        }
        Rol other = (Rol) object;
        if ((this.roCodigo == null && other.roCodigo != null) || (this.roCodigo != null && !this.roCodigo.equals(other.roCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ec.socialfun.entidades.Rol[ roCodigo=" + roCodigo + " ]";
    }
    
}
